﻿using System;
using System.Data;
using System.Data.OleDb;



namespace ik.DB.OleDb
{
    public class clDbOleDb : clDB
    {
        #region "ToString"
        /// <summary>
        /// class information
        /// </summary>
        /// <returns>String</returns>
        public override String ToString()
        {
            return "Class name: ik.DB.OleDb \n\n" +
                   "Class version: " + Environment.Version.ToString() + "\n" +
                   "OS version: " + Environment.OSVersion.ToString() + "\n" +
                   "Computer name: " + Environment.MachineName + "\n" +
                   "Rights: (c) 2011 - by Ivan Kruger";
        }
        #endregion

        /// <summary>
        /// contrutor
        /// </summary>
        public clDbOleDb()
            : base(enSGBD.OleDb)
        {
        }

        /// <summary>
        /// conecta ao banco de dados OleDb
        /// </summary>
        /// <param name="pathDb">caminho e banco de dados (mdb)</param>
        /// <param name="cnnTimeOut">tempo de conexão</param>
        public void GetCnn(String pathDb)
        {
            try
            {
                cnnString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;" + pathDb;

                if (cnnDB == null)
                    cnnDB = new OleDbConnection(cnnString);
                if (cnnDB.State != ConnectionState.Open)
                    cnnDB.Open();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }

}

